# -*- coding: utf-8; mode: snippet -*-
# name: postpone onChange until input stops for a while
# key: timeout
# contributor: Chen Bin <chenbin DOT sh AT gmail>
# --
if(${1:this.inputTimer}) {
  // kill the un-triggered old timer
  clearTimeout(${1:$(yas/substr yas-text "[^ ]*")});
  ${1:$(yas/substr yas-text "[^ ]*")} = null;
}
${1:$(yas/substr yas-text "[^ ]*")} = setTimeout(() => {
  ${1:$(yas/substr yas-text "[^ ]*")} = null;
  if (this.props.onChange) {
    this.props.onChange($0);
  }
}, 250);